package cn.demo.app.cloud;

import cn.demo.app.api.ShowApi;
import cn.ifloat.brick.basic.common.toolkit.Maper;
import cn.ifloat.brick.logger.core.LogKit;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author: float 2023/7/4 09:47
 */
@RestController
public class ShowServer implements ShowApi{

    @Override
    public Map<String,String> print(String msg) {
        ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
        HttpServletRequest request = sra.getRequest();
        LogKit.system().info("ShowServer.print :" + msg);
        System.out.println("ShowServer.print :" + msg);
        return  Maper.<String,String>builder().of("s",msg).get();
    }

    @Override
    public String str(String msg) {
        System.out.println("ShowServer.str :" + msg);
        return msg;
    }
}
